import java.util.Scanner;

/**
 * @Title: 判断子序列
 * @Author 贾金博
 * @Package PACKAGE_NAME
 * @Date 2024/3/3 21:14
 * @description: 双指针
 */
public class 判断子序列 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[n + 10];
        int[] b = new int[m + 10];
        for(int i = 1; i <= n; ++ i ) {
            a[i] = sc.nextInt();
        }

        for (int j = 1; j <= m; ++ j ) {
            b[j] = sc.nextInt();
        }

        int i = 1;
        int j = 1;
        for(i = 1, j = 1; i <= m && j <= n; ++ i ) { // 这里要防止 j 超出界
            if(a[j] == b[i]) {
                j++;
            }
        }
      //  System.out.println("j = " + j);
        if(j == n + 1) { // 说明指针已经达到这了
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}
/**
 * 1 2
 * 1
 * 1 0
 */
